Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Godzio 10 */
- #include <stdio.h>
- #include <math.h>
- #define SIZE 10
- float avg(float array[], int size) {
- float sum=0;
- int i;
- for (i=0; i<size; i++)
- sum += array[i];
- return sum/size;
- }
- float odchylenie(float array[], int size) {
- float avrg = avg(array, size);
- float result=0;
- float expression;
- int i;
- for (i=0; i<size; i++) {
- expression = array[i] - avrg;
- result += expression*expression;
- }
- result = sqrt(result/size);
- return result;
- }
- int main (void) {
- float tab[SIZE];
- int i;
- float E;
- float S;
- for (i=0; i<SIZE; i++) {
- tab[i] = sqrt(i);
- printf("tab[%d] = %f\n", i, tab[i]);
- }
- E = avg(tab, SIZE);
- printf("Srednia to: %f\n", E);
- S = odchylenie(tab, SIZE);
- printf("Odchylenie standardowe to: %f\n", S);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment